﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
    CodeBehind="Profile.aspx.vb" Inherits="mybaconrecipe.Profile" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <!-- LHS Pane consists of 3 listviews which have the same data source but show different fields -->
    <div id="lhsPane">
        <div id="profileHeader">
            <div id="imgprofileHeader">
                <asp:ListView ID="lst_ProfileHeader" runat="server" DataKeyNames="PROFILE_ID" DataSourceID="allProfileSqlDataSource">
                    <AlternatingItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("USER_PHOTO") %>' CssClass="profileImage" />
                    </AlternatingItemTemplate>
                    <EditItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("USER_PHOTO") %>' CssClass="profileImage" />
                    </EditItemTemplate>
                    <EmptyDataTemplate>
                        <span></span>
                    </EmptyDataTemplate>
                    <InsertItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("USER_PHOTO") %>' CssClass="profileImage" />
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("USER_PHOTO") %>' CssClass="profileImage" />
                    </ItemTemplate>
                    <LayoutTemplate>
                        <div id="itemPlaceholderContainer" runat="server" style="">
                            <span runat="server" id="itemPlaceholder" />
                        </div>
                        <div style="">
                        </div>
                    </LayoutTemplate>
                    <SelectedItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("USER_PHOTO") %>' CssClass="profileImage" />
                    </SelectedItemTemplate>
                </asp:ListView>
                <asp:SqlDataSource ID="allProfileSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:recipeConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:recipeConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [PROFILE_COUNTRY_VIEW] WHERE ([USER_UNAME] = ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="USER_UNAME" QueryStringField="User" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </div>
            <div id="namsurprofileHeader">
                <h1>
                    &nbsp;<asp:ListView ID="ListView1" runat="server" DataSourceID="allProfileSqlDataSource">
                        <AlternatingItemTemplate>
                            <span style="">
                                <asp:Label ID="USER_FNAMELabel" runat="server" Text='<%# Eval("USER_FNAME") %>' CssClass="MainContent_profile_FirstName" />
                                <br />
                                <asp:Label ID="USER_LNAMELabel" runat="server" Text='<%# Eval("USER_LNAME") %>' CssClass="MainContent_profile_FirstName" />
                                <br />
                                <br />
                            </span>
                        </AlternatingItemTemplate>
                        <EditItemTemplate>
                            <span style="">
                                <asp:TextBox ID="USER_FNAMETextBox" runat="server" Text='<%# Bind("USER_FNAME") %>'
                                    CssClass="MainContent_profile_FirstName" />
                                <br />
                                <asp:TextBox ID="USER_LNAMETextBox" runat="server" Text='<%# Bind("USER_LNAME") %>' />
                                <br />
                                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                                <br />
                                <br />
                            </span>
                        </EditItemTemplate>
                        <EmptyDataTemplate>
                            <p style="font-size:14px; color:Red; margin-top:10px;">Your Profile is still Empty. Please click on<br /> the Edit Profile Tab on the left to fill it in!<p>
                        </EmptyDataTemplate>
                        <InsertItemTemplate>
                            <span style="">
                                <asp:TextBox ID="USER_FNAMETextBox" runat="server" Text='<%# Bind("USER_FNAME") %>'
                                    CssClass="MainContent_profile_FirstName" />
                                <br />
                                <asp:TextBox ID="USER_LNAMETextBox" runat="server" Text='<%# Bind("USER_LNAME") %>' />
                                <br />
                                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                                <br />
                                <br />
                            </span>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <span style="">
                                <asp:Label ID="USER_FNAMELabel" runat="server" Text='<%# Eval("USER_FNAME") %>' CssClass="MainContent_profile_FirstName" />
                                <br />
                                <asp:Label ID="USER_LNAMELabel" runat="server" Text='<%# Eval("USER_LNAME") %>' />
                                <br />
                                <br />
                            </span>
                        </ItemTemplate>
                        <LayoutTemplate>
                            <div id="itemPlaceholderContainer" runat="server" style="">
                                <span runat="server" id="itemPlaceholder" />
                            </div>
                            <div style="">
                            </div>
                        </LayoutTemplate>
                        <SelectedItemTemplate>
                            <span style="">
                                <asp:Label ID="USER_FNAMELabel" runat="server" Text='<%# Eval("USER_FNAME") %>' CssClass="MainContent_profile_FirstName" />
                                <br />
                                <asp:Label ID="USER_LNAMELabel" runat="server" Text='<%# Eval("USER_LNAME") %>' />
                                <br />
                                <br />
                            </span>
                        </SelectedItemTemplate>
                    </asp:ListView>
                </h1>            
            </div>
            <div class="profileStatsContainer">
                <table cellpadding="0" cellspacing="0" id="profileStatsTable">
                    <tr>
                    <td class="profileStatsTdNum">
                        <asp:Label ID="lbl_ProfileStatsRecipes" runat="server" Text="Label">5</asp:Label>
                    </td>
                    <td class="profileStatsTdNum">
                        <asp:Label ID="lbl_ProfileStatsComments" runat="server"></asp:Label>
                    </td>
                    <td class="profileStatsTdNum">
                        <asp:Label ID="lbl_ProfileStatsRating" runat="server"></asp:Label>
                    </td>
                    </tr>
                    <tr>
                    <td class="profileStatsTdTxt">
                        Recipes
                    </td>
                    <td class="profileStatsTdTxt">
                        Comments
                    </td>
                    <td class="profileStatsTdTxt">
                        Ratings
                    </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="profileLinksContainer">
            <ul>
                <asp:ListView ID="lst_ProfileDetails" runat="server" DataSourceID="allProfileSqlDataSource">
                    <AlternatingItemTemplate>
                        <li><span class="profile_Label">From</span><br />
                            <asp:Label ID="CTRY_IDLabel" runat="server" Text='<%# Eval("CTRY_NAME") %>' />
                        </li>
                        <li><span class="profile_Label">Born On</span><br />
                            <asp:Label ID="USER_DOBLabel" runat="server" Text='<%# Eval("USER_DOB") %>' />
                        </li>
                        <li><span class="profile_Label">E-Mail</span><br />
                            <asp:Label ID="USER_EMAILLabel" runat="server" Text='<%# Eval("USER_EMAIL") %>' />
                        </li>
                        <li><span class="profile_Label">Bio</span><br />
                            <asp:Label ID="USER_BIOLabel" runat="server" Text='<%# Eval("USER_BIO") %>' />
                        </li>
                    </AlternatingItemTemplate>
                    <EditItemTemplate>
                        <li><span class="profile_Label">From</span><br />
                            <asp:Label ID="CTRY_IDLabel" runat="server" Text='<%# Eval("CTRY_NAME") %>' />
                        </li>
                        <li><span class="profile_Label">Born On</span><br />
                            <asp:Label ID="USER_DOBLabel" runat="server" Text='<%# Eval("USER_DOB") %>' />
                        </li>
                        <li><span class="profile_Label">E-Mail</span><br />
                            <asp:Label ID="USER_EMAILLabel" runat="server" Text='<%# Eval("USER_EMAIL") %>' />
                        </li>
                        <li><span class="profile_Label">Bio</span><br />
                            <asp:Label ID="USER_BIOLabel" runat="server" Text='<%# Eval("USER_BIO") %>' />
                        </li>
                    </EditItemTemplate>
                    <EmptyDataTemplate>
                        <span></span>
                    </EmptyDataTemplate>
                    <InsertItemTemplate>
                        <li><span class="profile_Label">From</span><br />
                            <asp:Label ID="CTRY_IDLabel" runat="server" Text='<%# Eval("CTRY_NAME") %>' />
                        </li>
                        <li><span class="profile_Label">Born On</span><br />
                            <asp:Label ID="USER_DOBLabel" runat="server" Text='<%# Eval("USER_DOB") %>' />
                        </li>
                        <li><span class="profile_Label">E-Mail</span><br />
                            <asp:Label ID="USER_EMAILLabel" runat="server" Text='<%# Eval("USER_EMAIL") %>' />
                        </li>
                        <li><span class="profile_Label">Bio</span><br />
                            <asp:Label ID="USER_BIOLabel" runat="server" Text='<%# Eval("USER_BIO") %>' />
                        </li>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <li><span class="profile_Label">From</span><br />
                            <asp:Label ID="CTRY_IDLabel" runat="server" Text='<%# Eval("CTRY_NAME") %>' />
                        </li>
                        <li><span class="profile_Label">Born On</span><br />
                            <asp:Label ID="USER_DOBLabel" runat="server" Text='<%# Eval("USER_DOB") %>' />
                        </li>
                        <li><span class="profile_Label">E-Mail</span><br />
                            <asp:Label ID="USER_EMAILLabel" runat="server" Text='<%# Eval("USER_EMAIL") %>' />
                        </li>
                        <li><span class="profile_Label">Bio</span><br />
                            <asp:Label ID="USER_BIOLabel" runat="server" Text='<%# Eval("USER_BIO") %>' />
                        </li>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <div id="itemPlaceholderContainer" runat="server" style="">
                            <span runat="server" id="itemPlaceholder" />
                        </div>
                        <div style="">
                        </div>
                    </LayoutTemplate>
                    <SelectedItemTemplate>
                        <li><span class="profile_Label">From</span><br />
                            <asp:Label ID="CTRY_IDLabel" runat="server" Text='<%# Eval("CTRY_NAME") %>' />
                        </li>
                        <li><span class="profile_Label">Born On</span><br />
                            <asp:Label ID="USER_DOBLabel" runat="server" Text='<%# Eval("USER_DOB") %>' />
                        </li>
                        <li><span class="profile_Label">E-Mail</span><br />
                            <asp:Label ID="USER_EMAILLabel" runat="server" Text='<%# Eval("USER_EMAIL") %>' />
                        </li>
                        <li><span class="profile_Label">Bio</span><br />
                            <asp:Label ID="USER_BIOLabel" runat="server" Text='<%# Eval("USER_BIO") %>' />
                        </li>
                    </SelectedItemTemplate>
                </asp:ListView>
            </ul>
        </div>
    </div>
    <div id="rhsPane">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:TabContainer ID="profileTabs" runat="server" ActiveTabIndex="0" UseVerticalStripPlacement="False"
            CssClass="MyTabStyle">
            <!-- Tab 1: Recipes Uploaded -->
            <asp:TabPanel runat="server" HeaderText="Recipes" ID="TabPanel1">
                <ContentTemplate>
                    <asp:GridView ID="grd_ActivityRecipes" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        DataSourceID="ProfileRecipeSqlDataSource" CssClass="grd_profileRecipeStyle" PageSize="20">
                        <Columns>
                            <asp:ImageField DataImageUrlField="REC_IMAGE">
                                <ControlStyle CssClass="activityThumb" />
                            </asp:ImageField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <span class="profileDate"><%# Eval("REC_DATE")%></span><br />
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "REC_ID", "RecipeDetail.aspx?ID={0}") %>'>
                                        <%# DataBinder.Eval(Container.DataItem, "REC_NAME") %></a>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "REC_ID", "EditRecipe.aspx?ID={0}") %>'><img src="ui/icnEdit.png" class="frmIcon" title="Edit Recipe" alt="Edit Recipe" /></a>  
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "REC_ID", "DeleteRecipe.aspx?ID={0}") %>'><img src="ui/icnDelete.png" class="frmIconDel" title="Delete Recipe" alt="Delete Recipe" /></a>
                                </ItemTemplate>
                            </asp:TemplateField>                                                                         
                        </Columns>
                        <HeaderStyle CssClass="notVis" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="ProfileRecipeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:recipeConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:recipeConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [PROFILE_RECIPE_VIEW] WHERE ([USER_UNAME] = ?) ORDER BY REC_DATE DESC">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="USER_UNAME" QueryStringField="USER" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:TabPanel>
            <!-- Tab 2: Comments Placed -->
            <asp:TabPanel runat="server" HeaderText="Comments" ID="TabPanel2">
                <ContentTemplate>
                    <asp:GridView ID="grd_ActivityComments" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        DataSourceID="ProfileCommentsSqlDataSource"  CssClass="grd_profileRecipeStyle" PageSize="20">
                        <Columns>
                            <asp:ImageField DataImageUrlField="REC_IMAGE">
                                <ControlStyle CssClass="activityThumb" />
                            </asp:ImageField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <span class="profileDate"><%# Eval("COMM_DATE")%></span><br />
                                    <span class="profileDate">ON: </span><a href='<%# DataBinder.Eval(Container.DataItem, "REC_ID", "RecipeDetail.aspx?ID={0}") %>'>
                                        <%# DataBinder.Eval(Container.DataItem, "REC_NAME") %></a><br />
                                    <p class="profileCommStyle"><%# Eval("COMM_DESC")%></p>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "COMM_ID", "DeleteComment.aspx?ID={0}") %>'><img src="ui/icnDelete.png" class="frmIconDel" title="Delete Comment" alt="Delete Comment" /></a>
                                </ItemTemplate>
                            </asp:TemplateField>     
                        </Columns>
                        <HeaderStyle CssClass="notVis" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="ProfileCommentsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:recipeConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:recipeConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [PROFILE_COMMENT_RECIPE_VIEW] WHERE ([USER_UNAME] = ?) ORDER BY COMM_DATE DESC">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="USER_UNAME" QueryStringField="USER" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:TabPanel>

            <!-- Tab 3: Ratings -->
            <asp:TabPanel runat="server" HeaderText="Ratings" ID="TabPanel4">
                <ContentTemplate>
                    <asp:GridView ID="grd_ActivityRatings" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        DataSourceID="ProfileActivitySqlDataSource"  CssClass="grd_profileRecipeStyle" PageSize="20">
                        <Columns>
                            <asp:ImageField DataImageUrlField="REC_IMAGE">
                                <ControlStyle CssClass="activityThumb" />
                            </asp:ImageField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <span class="profileDate"><%# Eval("RATING_DATE")%></span><br />
                                    <span class="profileDate">ON: </span><a href='<%# DataBinder.Eval(Container.DataItem, "REC_ID", "RecipeDetail.aspx?ID={0}") %>'>
                                        <%# DataBinder.Eval(Container.DataItem, "REC_NAME") %></a><br />
                                    <p class="profileCommStyle"><%# Eval("RATING_VALUE") & " Bacon Strips" %></p>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <a href='<%# DataBinder.Eval(Container.DataItem, "RATING_ID", "DeleteRating.aspx?ID={0}") %>'><img src="ui/icnDelete.png" class="frmIconDel" title="Delete Rating" alt="Delete Rating" /></a>
                                </ItemTemplate>
                            </asp:TemplateField>     
                        </Columns>
                        <HeaderStyle CssClass="notVis" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="ProfileActivitySqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:recipeConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:recipeConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [PROFILE_RATING_RECIPE_VIEW] WHERE ([USER_UNAME] = ?) ORDER BY RATING_DATE DESC">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="USER_UNAME" QueryStringField="USER" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:TabPanel>

            <!-- Tab 4: Edit Profile -->
            <asp:TabPanel runat="server" HeaderText="Edit Profile" ID="TabPanel3">
                <ContentTemplate>
                    <table cellpadding="0" cellspacing="0" class="frmTable">
                        <tr>
                            <td class="lbl_frmTable">
                                First Name
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:TextBox ID="tb_PrFName" runat="server" CssClass="textEntry"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                Last Name
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:TextBox ID="tb_PrLName" runat="server" CssClass="textEntry"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                Country
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:DropDownList ID="ddl_PrCountry" runat="server" DataSourceID="CountryDataSource"
                                    DataTextField="CTRY_NAME" DataValueField="CTRY_ID" CssClass="textEntry">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="CountryDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:recipeConnectionString %>"
                                    ProviderName="<%$ ConnectionStrings:recipeConnectionString.ProviderName %>" SelectCommand="SELECT [CTRY_ID], [CTRY_NAME] FROM [COUNTRY] ORDER BY [CTRY_NAME]">
                                </asp:SqlDataSource>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                Date Of Birth
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:TextBox ID="tb_PrDOB" runat="server" CssClass="textEntry"></asp:TextBox>
                                <asp:CalendarExtender ID="tb_PrDOB_CalendarExtender" runat="server" Enabled="True"
                                    TargetControlID="tb_PrDOB">
                                </asp:CalendarExtender>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                E-Mail Address
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:TextBox ID="tb_PrEmail" runat="server" CssClass="textEntry"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                Biography
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:TextBox ID="tb_PrBio" runat="server" CssClass="textEntry" TextMode="MultiLine"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="lbl_frmTable">
                                Photo
                            </td>
                        </tr>
                        <tr>
                            <td class="inp_frmTable">
                                <asp:FileUpload ID="fup_PrPhoto" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="btn_PrSaveProfile" runat="server" Text="Save Profile" CssClass="btn_Form" />
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:TabPanel>
        </asp:TabContainer>
    </div>
    <p>
        <br />
    </p>
</asp:Content>
